<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    账号:<input type="text"> <button>禁用</button><button>解禁</button>  </br>
    密码:<input type="password">
        
    <script>
        let name = document.getElementsByTagName('input')[0]
        let pwd = document.getElementsByTagName('input')[1]
        let btn1 = document.getElementsByTagName('button')[0]
        let btn2 = document.getElementsByTagName('button')[1]

        btn1.onclick = function(){
            name.disabled = 'no' //禁用文本框。属性值里随便写什么字符串都行，但不能为空。
        }

        btn2.onclick = function(){
            // name.disabled = false //解禁文本框
            name.removeAttribute('disabled')  //删除disabled属性
        }
    </script>
</body>
</html>